package com.vshining.cryptoki.jna.pkcs11;

import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.vshining.cryptoki.jna.pkcs11f.*;
import com.vshining.cryptoki.jna.pkcs11t.CK_VERSION;

import java.util.Arrays;
import java.util.List;

/**
 * class CK_FUNCTION_LIST is a structure holding a Cryptoki spec version and
 * pointers of appropriate types to all the Cryptoki functions. <br>
 * <em>CK_FUNCTION_LIST is new for v2.0</em> <B>PKCS#11 structure:</B>
 * <p/>
 * <pre>
 * typedef struct CK_FUNCTION_LIST {
 *     CK_VERSION version
 *     #include "pkcs11f.h"
 * } CK_FUNCTION_LIST;
 * </pre>
 *
 * @author ShanMiao
 * @author WangXuanmin
 */
@SuppressWarnings("unused")
public class CK_FUNCTION_LIST extends Structure {
    public CK_VERSION version;
    public CK_C_Initialize C_Initialize;
    public CK_C_Finalize C_Finalize;
    public CK_C_GetInfo C_GetInfo;
    public CK_C_GetFunctionList C_GetFunctionList;
    public CK_C_GetSlotList C_GetSlotList;
    public CK_C_GetSlotInfo C_GetSlotInfo;
    public CK_C_GetTokenInfo C_GetTokenInfo;
    public CK_C_GetMechanismList C_GetMechanismList;
    public CK_C_GetMechanismInfo C_GetMechanismInfo;
    public CK_C_InitToken C_InitToken;
    public CK_C_InitPIN C_InitPIN;
    public CK_C_SetPIN C_SetPIN;
    public CK_C_OpenSession C_OpenSession;
    public CK_C_CloseSession C_CloseSession;
    public CK_C_CloseAllSessions C_CloseAllSessions;
    public CK_C_GetSessionInfo C_GetSessionInfo;
    public CK_C_GetOperationState C_GetOperationState;
    public CK_C_SetOperationState C_SetOperationState;
    public CK_C_Login C_Login;
    public CK_C_Logout C_Logout;
    public CK_C_CreateObject C_CreateObject;
    public CK_C_CopyObject C_CopyObject;
    public CK_C_DestroyObject C_DestroyObject;
    public CK_C_GetObjectSize C_GetObjectSize;
    public CK_C_GetAttributeValue C_GetAttributeValue;
    public CK_C_SetAttributeValue C_SetAttributeValue;
    public CK_C_FindObjectsInit C_FindObjectsInit;
    public CK_C_FindObjects C_FindObjects;
    public CK_C_FindObjectsFinal C_FindObjectsFinal;
    public CK_C_EncryptInit C_EncryptInit;
    public CK_C_Encrypt C_Encrypt;
    public CK_C_EncryptUpdate C_EncryptUpdate;
    public CK_C_EncryptFinal C_EncryptFinal;
    public CK_C_DecryptInit C_DecryptInit;
    public CK_C_Decrypt C_Decrypt;
    public CK_C_DecryptUpdate C_DecryptUpdate;
    public CK_C_DecryptFinal C_DecryptFinal;
    public CK_C_DigestInit C_DigestInit;
    public CK_C_Digest C_Digest;
    public CK_C_DigestUpdate C_DigestUpdate;
    public CK_C_DigestKey C_DigestKey;
    public CK_C_DigestFinal C_DigestFinal;
    public CK_C_SignInit C_SignInit;
    public CK_C_Sign C_Sign;
    public CK_C_SignUpdate C_SignUpdate;
    public CK_C_SignFinal C_SignFinal;
    public CK_C_SignRecoverInit C_SignRecoverInit;
    public CK_C_SignRecover C_SignRecover;
    public CK_C_VerifyInit C_VerifyInit;
    public CK_C_Verify C_Verify;
    public CK_C_VerifyUpdate C_VerifyUpdate;
    public CK_C_VerifyFinal C_VerifyFinal;
    public CK_C_VerifyRecoverInit C_VerifyRecoverInit;
    public CK_C_VerifyRecover C_VerifyRecover;
    public CK_C_DigestEncryptUpdate C_DigestEncryptUpdate;
    public CK_C_DecryptDigestUpdate C_DecryptDigestUpdate;
    public CK_C_SignEncryptUpdate C_SignEncryptUpdate;
    public CK_C_DecryptVerifyUpdate C_DecryptVerifyUpdate;
    public CK_C_GenerateKey C_GenerateKey;
    public CK_C_GenerateKeyPair C_GenerateKeyPair;
    public CK_C_WrapKey C_WrapKey;
    public CK_C_UnwrapKey C_UnwrapKey;
    public CK_C_DeriveKey C_DeriveKey;
    public CK_C_SeedRandom C_SeedRandom;
    public CK_C_GenerateRandom C_GenerateRandom;
    public CK_C_GetFunctionStatus C_GetFunctionStatus;
    public CK_C_CancelFunction C_CancelFunction;
    public CK_C_WaitForSlotEvent C_WaitForSlotEvent;

    @Override
    protected List getFieldOrder() {
        return Arrays.asList(
                "version",
                "C_Initialize",
                "C_Finalize",
                "C_GetInfo",
                "C_GetFunctionList",
                "C_GetSlotList",
                "C_GetSlotInfo",
                "C_GetTokenInfo",
                "C_GetMechanismList",
                "C_GetMechanismInfo",
                "C_InitToken",
                "C_InitPIN",
                "C_SetPIN",
                "C_OpenSession",
                "C_CloseSession",
                "C_CloseAllSessions",
                "C_GetSessionInfo",
                "C_GetOperationState",
                "C_SetOperationState",
                "C_Login",
                "C_Logout",
                "C_CreateObject",
                "C_CopyObject",
                "C_DestroyObject",
                "C_GetObjectSize",
                "C_GetAttributeValue",
                "C_SetAttributeValue",
                "C_FindObjectsInit",
                "C_FindObjects",
                "C_FindObjectsFinal",
                "C_EncryptInit",
                "C_Encrypt",
                "C_EncryptUpdate",
                "C_EncryptFinal",
                "C_DecryptInit",
                "C_Decrypt",
                "C_DecryptUpdate",
                "C_DecryptFinal",
                "C_DigestInit",
                "C_Digest",
                "C_DigestUpdate",
                "C_DigestKey",
                "C_DigestFinal",
                "C_SignInit",
                "C_Sign",
                "C_SignUpdate",
                "C_SignFinal",
                "C_SignRecoverInit",
                "C_SignRecover",
                "C_VerifyInit",
                "C_Verify",
                "C_VerifyUpdate",
                "C_VerifyFinal",
                "C_VerifyRecoverInit",
                "C_VerifyRecover",
                "C_DigestEncryptUpdate",
                "C_DecryptDigestUpdate",
                "C_SignEncryptUpdate",
                "C_DecryptVerifyUpdate",
                "C_GenerateKey",
                "C_GenerateKeyPair",
                "C_WrapKey",
                "C_UnwrapKey",
                "C_DeriveKey",
                "C_SeedRandom",
                "C_GenerateRandom",
                "C_GetFunctionStatus",
                "C_CancelFunction",
                "C_WaitForSlotEvent"
        );
    }


    public CK_FUNCTION_LIST(Pointer p) {
        super(p);
    }

    public CK_FUNCTION_LIST(Pointer p, int alignType) {
        super(p, alignType);
    }

}
